package com.icexxx.icegen.template;

import java.util.HashMap;

import com.icexxx.icegen.codemanager.Count;
import com.icexxx.icegen.codemanager.Data;
import com.icexxx.icegen.codemanager.Template;

public class PomTemplate implements Template {

    @Override
    public String getCode(HashMap<String, String> dataMap, Data data, String packageName, String className) {
        StringBuilder sum = new StringBuilder();
        String nl = Count.NEWLINE;
        String pack = dataMap.get("domain");
        String projectName = dataMap.get("projectName");
        sum.append(
                "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
                        + nl);
        sum.append(
                "  xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">"
                        + nl);
        sum.append("    <modelVersion>4.0.0</modelVersion>" + nl);
        sum.append("    <groupId>" + pack + "</groupId>" + nl);
        sum.append("    <artifactId>" + projectName + "</artifactId>" + nl);
        sum.append("    <packaging>war</packaging>" + nl);
        sum.append("    <version>1.0.0</version>" + nl);
        sum.append("    <name>" + projectName + " Maven Webapp</name>" + nl);
        sum.append("    <url>http://maven.apache.org</url>" + nl);
        sum.append("    <properties>" + nl);
        sum.append("        <project.build.sourceEncoding>" + nl);
        sum.append("            UTF-8" + nl);
        sum.append("        </project.build.sourceEncoding>" + nl);
        sum.append("    </properties>" + nl);
        sum.append("    <dependencies>" + nl);
        sum.append("        <!-- spring-core包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-core</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- spring-context包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-context</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- spring-tx包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-tx</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- spring-jdbc包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-jdbc</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!--spring-web包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-web</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- springmvc核心包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-webmvc</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- spring-test包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.springframework</groupId>" + nl);
        sum.append("            <artifactId>spring-test</artifactId>" + nl);
        sum.append("            <version>4.3.14.RELEASE</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- aspectjweaver包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.aspectj</groupId>" + nl);
        sum.append("            <artifactId>aspectjweaver</artifactId>" + nl);
        sum.append("            <version>1.8.5</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- mybatis核心包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.mybatis</groupId>" + nl);
        sum.append("            <artifactId>mybatis</artifactId>" + nl);
        sum.append("            <version>3.4.5</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- mybatis与Spring整合的核心包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.mybatis</groupId>" + nl);
        sum.append("            <artifactId>mybatis-spring</artifactId>" + nl);
        sum.append("            <version>1.3.1</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- servlet3.0核心包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>javax.servlet</groupId>" + nl);
        sum.append("            <artifactId>javax.servlet-api</artifactId>" + nl);
        sum.append("            <version>3.0.1</version>" + nl);
        sum.append("             <scope>provided</scope>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>javax.servlet.jsp</groupId>" + nl);
        sum.append("            <artifactId>javax.servlet.jsp-api</artifactId>" + nl);
        sum.append("            <version>2.3.2-b01</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- jstl -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>javax.servlet</groupId>" + nl);
        sum.append("            <artifactId>jstl</artifactId>" + nl);
        sum.append("            <version>1.2</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- mysql驱动包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>mysql</groupId>" + nl);
        sum.append("            <artifactId>mysql-connector-java</artifactId>" + nl);
        sum.append("            <version>5.1.45</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- druid连接池包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.alibaba</groupId>" + nl);
        sum.append("            <artifactId>druid</artifactId>" + nl);
        sum.append("            <version>1.1.8</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- jackson三个包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.fasterxml.jackson.core</groupId>" + nl);
        sum.append("            <artifactId>jackson-core</artifactId>" + nl);
        sum.append("            <version>2.9.4</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.fasterxml.jackson.core</groupId>" + nl);
        sum.append("            <artifactId>jackson-databind</artifactId>" + nl);
        sum.append("            <version>2.9.4</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.fasterxml.jackson.core</groupId>" + nl);
        sum.append("            <artifactId>jackson-annotations</artifactId>" + nl);
        sum.append("            <version>2.9.4</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- 日志三个包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.slf4j</groupId>" + nl);
        sum.append("            <artifactId>slf4j-log4j12</artifactId>" + nl);
        sum.append("            <version>1.7.25</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>org.slf4j</groupId>" + nl);
        sum.append("            <artifactId>slf4j-api</artifactId>" + nl);
        sum.append("            <version>1.7.25</version>" + nl);
        sum.append("        </dependency>  " + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>log4j</groupId>" + nl);
        sum.append("            <artifactId>log4j</artifactId>" + nl);
        sum.append("            <version>1.2.17</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- 实体类日期转换 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.icexxx</groupId>" + nl);
        sum.append("            <artifactId>iceformat</artifactId>" + nl);
        sum.append("            <version>1.0</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- 请求日志 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.icexxx</groupId>" + nl);
        sum.append("            <artifactId>icefilter</artifactId>" + nl);
        sum.append("            <version>1.1</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- sql日志 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>com.googlecode.log4jdbc</groupId>" + nl);
        sum.append("            <artifactId>log4jdbc</artifactId>" + nl);
        sum.append("            <version>1.2</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- hutool工具包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>cn.hutool</groupId>" + nl);
        sum.append("            <artifactId>hutool-all</artifactId>" + nl);
        sum.append("            <version>5.8.35</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- tomcat部署 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>se.jiderhamn.classloader-leak-prevention</groupId>" + nl);
        sum.append("            <artifactId>classloader-leak-prevention-servlet</artifactId>" + nl);
        sum.append("            <version>2.1.0</version>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("        <!-- junit单元测试包 -->" + nl);
        sum.append("        <dependency>" + nl);
        sum.append("            <groupId>junit</groupId>" + nl);
        sum.append("            <artifactId>junit</artifactId>" + nl);
        sum.append("            <version>4.12</version>" + nl);
        sum.append("            <scope>test</scope>" + nl);
        sum.append("        </dependency>" + nl);
        sum.append("    </dependencies>" + nl);
        sum.append("    <build>" + nl);
        sum.append("        <finalName>" + projectName + "</finalName>" + nl);
        sum.append("        <resources>" + nl);
        sum.append("            <resource>" + nl);
        sum.append("                <directory>src/main/java</directory>" + nl);
        sum.append("                <includes>" + nl);
        sum.append("                    <include>**/*.xml</include>" + nl);
        sum.append("                </includes>" + nl);
        sum.append("                <filtering>true</filtering>" + nl);
        sum.append("            </resource>" + nl);
        sum.append("            <resource>" + nl);
        sum.append("                <directory>src/main/resources</directory>" + nl);
        sum.append("                <includes>" + nl);
        sum.append("                    <include>**/*.xml</include>" + nl);
        sum.append("                    <include>**/*.properties</include>" + nl);
        sum.append("                </includes>" + nl);
        sum.append("                <filtering>true</filtering>" + nl);
        sum.append("            </resource>" + nl);
        sum.append("        </resources>" + nl);
        sum.append("        <plugins>" + nl);
        sum.append("            <plugin>" + nl);
        sum.append("                <groupId>org.apache.maven.plugins</groupId>" + nl);
        sum.append("                <artifactId>maven-compiler-plugin</artifactId>" + nl);
        sum.append("                <version>3.7.0</version>" + nl);
        sum.append("                <configuration>" + nl);
        sum.append("                    <encoding>UTF-8</encoding>" + nl);
        sum.append("                    <source>1.8</source>" + nl);
        sum.append("                    <target>1.8</target>" + nl);
        sum.append("                    <skipTests>true</skipTests>" + nl);
        sum.append("                    <testFailureIgnore>true</testFailureIgnore>" + nl);
        sum.append("                </configuration>" + nl);
        sum.append("            </plugin>" + nl);
        sum.append("            <plugin>" + nl);
        sum.append("" + nl);
        sum.append("                <groupId>org.apache.tomcat.maven</groupId>" + nl);
        sum.append("                <artifactId>tomcat7-maven-plugin</artifactId>" + nl);
        sum.append("                <version>2.2</version>" + nl);
        sum.append("" + nl);
        sum.append("                <configuration>" + nl);
        sum.append("                    <!-- tomcat7:redeploy -->" + nl);
        sum.append("                    <url>http://127.0.0.1:8080/manager/text</url>" + nl);
        sum.append("                    <username>admin</username>" + nl);
        sum.append("                    <password>admin</password>" + nl);
        sum.append("                    <update>true</update>" + nl);
        sum.append("                    <path>/${project.artifactId}</path>" + nl);
        sum.append("                </configuration>" + nl);
        sum.append("            </plugin>" + nl);
        sum.append("        </plugins>" + nl);
        sum.append("    </build>" + nl);
        sum.append("</project>" + nl);
        String content = sum.toString();
        return content;
    }
}
